package org.fall.system.config;

import org.fall.system.exception.DeleteFailedException;
import org.fall.system.model.ResultEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 异常处理类
 * @author zjh
 * @since 2021/4/9 10:30
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 统一处理异常
     * @param request request
     * @param exception exception
     * @return ResultEntity
     */
    @ExceptionHandler
    @ResponseBody
    public ResultEntity globalExceptionHandler(HttpServletRequest request, RuntimeException exception) {
        return ResultEntity.failed(exception.getMessage());
    }



}
